clc;
clear all;
close all;

BER_8x24_180 = [0.02039757 0.00269118 0.00020979 0.00000381 0.00000008];
FER_8x24_180 = [0.48000000 0.07942812 0.00646412 0.00030527 0.00012335];
BER_8x24_90 =  [0.02432118 0.00835322 0.00161123 0.00018240 0.00001164 0.00000067];
FER_8x24_90 =  [0.51250000 0.20449898 0.04201681 0.00545375 0.00044257 0.00009626];
BER_8x24_45 =  [0.02574653 0.01323958 0.00464720 0.00153911 0.00038848 0.00006035 0.00000755 0.00000168 0.00000046];
FER_8x24_45 =  [0.51750000 0.26750000 0.11160714 0.03742515 0.01035947 0.00187038 0.00032968 0.00011377 0.00005277];


SNR_9x27_10 = 0.0:0.2:3.0;
SNR_9x27_20 = 0.0:0.2:2.6;
SNR_9x27_40 = 0.0:0.2:1.8;
SNR_9x27_60 = 0.0:0.2:1.4;
SNR_9x27_80 = 0.0:0.2:1.0;
SNR_9x27_120 = 0.0:0.2:0.8;
SNR_9x27_160 = 0.0:0.2:0.8;
BER_9x27_10 =  [0.02551389 0.02025000 0.01322810 0.00863586 0.00448969 0.00272462 0.00153692 0.00055813 0.00029943 0.00012747 0.00003850 0.00002688 0.00001070 0.00000801 0.00000355 0.00000289];
FER_9x27_10 =  [0.43500000 0.35250000 0.22026432 0.16501650 0.09049774 0.05467469 0.03394433 0.01323627 0.00763417 0.00377986 0.00180933 0.00132557 0.00090414 0.00072061 0.00037360 0.00036420];
BER_9x27_20 =  [0.02534028 0.01362500 0.00916770 0.00382007 0.00180767 0.00054336 0.00017113 0.00006967 0.00001902 0.00000714 0.00000350 0.00000204 0.00000110 0.00000067];
FER_9x27_20 =  [0.47500000 0.28750000 0.18656716 0.09041591 0.04113534 0.01613944 0.00544722 0.00276824 0.00108015 0.00057857 0.00031899 0.00021486 0.00013896 0.00008330];
BER_9x27_40 =  [0.02011806 0.00911477 0.00427540 0.00122019 0.00021815 0.00005156 0.00001016 0.00000236 0.00000122 0.00000071];
FER_9x27_40 =  [0.44750000 0.21978022 0.10438413 0.03582945 0.00909504 0.00252729 0.00096530 0.00044703 0.00030338 0.00019797];
BER_9x27_60 =  [0.01793056 0.00654343 0.00236186 0.00044921 0.00005004 0.00000605 0.00000127 0.00000077];
FER_9x27_60 =  [0.42750000 0.18083183 0.06472492 0.01414427 0.00263999 0.00085590 0.00045763 0.00028997];
BER_9x27_80 =  [0.02000347 0.00527906 0.00097853 0.00015579 0.00000977 0.00000076];
FER_9x27_80 =  [0.48250000 0.15432099 0.03066544 0.00604339 0.00081950 0.00034862];
BER_9x27_120 = [0.01483796 0.00342269 0.00038736 0.00002003 0.00000059];
FER_9x27_120 = [0.37500000 0.10593220 0.01324503 0.00118424 0.00044807];
BER_9x27_160 = [0.01314149 0.00209417 0.00012502 0.00000324 0.00000029];
FER_9x27_160 = [0.36250000 0.06934813 0.00499376 0.00062261 0.00046443];

SNR_6x30_60 = 1.0:0.2:3.0;
SNR_6x30_80 = 1.0:0.2:2.6;
SNR_6x30_100 = 1.0:0.2:2.6;
SNR_6x30_120 = 1.0:0.2:2.4;
SNR_6x30_160 = 1.0:0.2:2.4;
BER_6x30_60 =  [0.04431250 0.03584896 0.02407465 0.01442188 0.00540891 0.00157137 0.00028491 0.00004391 0.00000560 0.00000256 0.00000096];
BER_6x30_80 =  [];
BER_6x30_100 = [];
BER_6x30_120 = [];
BER_6x30_160 = [0.04464388 0.03668229 0.02734701 0.01205078 0.00202809 0.00011527 0.00000291 0.00000097];

SNR_6x18_15 = 0.0:0.2:3.0;
SNR_6x18_30 = 0.0:0.2:2.2;
SNR_6x18_90 = 0.0:0.2:1.2;
BER_6x18_15 = [0.03666667 0.02988889 0.01668056 0.01295940 0.00787302 0.00365643 0.00171796 0.00078307 0.00036639 0.00011492 0.00004661 0.00001981 0.00000777 0.00000197 0.00000213 0.00000083];
BER_6x18_30 = [0.03138194 0.02304167 0.01348393 0.00743100 0.00219058 0.00083422 0.00024022 0.00005542 0.00001402 0.00000218 0.00000113 0.00000063];
BER_6x18_90 = [0.02625463 0.00977601 0.00281085 0.00064296 0.00005147 0.00000271 0.00000177 0.00000134 0.00000069];

SNR_4x20_90 = 1.0:0.2:3.0;
SNR_4x20_120 = 1.0:0.2:2.6;
SNR_4x20_150 = 1.0:0.2:2.6;
SNR_4x20_180 = 1.0:0.2:2.4;
SNR_4x20_240 = 1.0:0.2:2.4;
BER_4x20_90 =  [0.04475000 0.03693056 0.02725868 0.01609722 0.00693229 0.00163485 0.00031508 0.00004073 0.00000425 0.00000111 0.00000039];
FER_4x20_90 =  [0.99250000 0.95750000 0.82000000 0.56000000 0.27000000 0.07272727 0.01641497 0.00297876 0.00075964 0.00041448 0.00025436];
BER_4x20_120 = [0.04472135 0.03672656 0.02687891 0.01491406 0.00509344 0.00106126 0.00011226 0.00000977 0.00000084];
FER_4x20_120 = [0.99750000 0.96250000 0.82250000 0.53000000 0.21008403 0.05015045 0.00579542 0.00087046 0.00026878];
BER_4x20_150 = [0.04525521 0.03800000 0.02696354 0.01377500 0.00447206 0.00061717 0.00004010 0.00000213 0.00000045];
FER_4x20_150 = [1.00000000 0.99500000 0.85000000 0.52000000 0.19493177 0.03130870 0.00320379 0.00068998 0.00037467];
BER_4x20_180 = [0.04534462 0.03870052 0.02851389 0.01338021 0.00383547 0.00045727 0.00001675 0.00000087];
FER_4x20_180 = [1.00000000 0.99750000 0.88750000 0.50500000 0.17094017 0.02205558 0.00124335 0.00030267];
BER_4x20_240 = [0.04533073 0.03812174 0.02756706 0.01299544 0.00263950 0.00014829 0.00000292 0.00000010];
FER_4x20_240 = [1.00000000 0.99750000 0.91250000 0.51250000 0.12562814 0.00899281 0.00059792 0.00025560];

BER_2d3r_1080 = [0.02459722 0.01619097 0.00598107 0.00159790 0.00047149 0.00011630 0.00002000 0.00000752 0.00000333 0.00000167];
FER_2d3r_1080 = [0.55500000 0.39000000 0.17211704 0.04854369 0.01787630 0.00505663 0.00181386 0.00106417 0.00072108 0.00042535];
BER_2d3r_2160 = [0.02282465 0.00940799 0.00201711 0.00031882 0.00002896 0.00000303];
FER_2d3r_2160 = [0.59750000 0.26000000 0.06357279 0.01484781 0.00219848 0.00100322];
BER_2d3r_4320 = [0.02230035 0.00543871 0.00051106 0.00000798 0.00000064];
FER_2d3r_4320 = [0.61750000 0.19011407 0.02039984 0.00171397 0.00113208];

BER_4d5r_1800 = [0.04200694 0.03370139 0.02480729 0.01612674 0.00673958 0.00195832 0.00056515 0.00009503 0.00001338 0.00000427 0.00000152];
FER_4d5r_1800 = [1.00000000 0.96500000 0.87500000 0.67750000 0.32500000 0.10976948 0.03580380 0.00844737 0.00222767 0.00100457 0.00048342];
BER_4d5r_2400 = [0.04103776 0.03434766 0.02448958 0.01411849 0.00563281 0.00178474 0.00023206 0.00003090 0.00000465];
FER_4d5r_2400 = [1.00000000 0.97250000 0.87250000 0.60250000 0.27000000 0.10040161 0.01877582 0.00330338 0.00123094];
BER_4d5r_3000 = [0.04127188 0.03417500 0.02574583 0.01473854 0.00504479 0.00120140 0.00012903 0.00001438 0.00000241];
FER_4d5r_3000 = [1.00000000 0.99250000 0.90750000 0.67000000 0.26500000 0.07112376 0.01071926 0.00232547 0.00095685];
BER_4d5r_3600 = [0.04120313 0.03431076 0.02625608 0.01353646 0.00485938 0.00070467 0.00006098 0.00000289];
FER_4d5r_3600 = [1.00000000 0.99250000 0.94000000 0.61750000 0.25750000 0.04395604 0.00614515 0.00117171];
BER_4d5r_4800 = [0.04116732 0.03430339 0.02540560 0.01399284 0.00377548 0.00033647 0.00001671 0.00000129];
FER_4d5r_4800 = [1.00000000 0.99500000 0.96000000 0.66250000 0.21459227 0.02427774 0.00254758 0.00077022];




figure(1);
semilogy(SNR_9x27_10, BER_9x27_10, '-*k');
hold on;
semilogy(SNR_9x27_20, BER_9x27_20, '-ok');
hold on;
semilogy(SNR_9x27_40, BER_9x27_40, '-sk');
hold on;
semilogy(SNR_9x27_60, BER_9x27_60, '->k');
hold on;
semilogy(SNR_9x27_80, BER_9x27_80, '-<k');
hold on;
semilogy(SNR_9x27_120, BER_9x27_120, '-xk');
hold on;
semilogy(SNR_9x27_160, BER_9x27_160, '-dk');
grid on;
title('BER of 2/3 QC-LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER');
legend('z=10', 'z=20', 'z=40', 'z=60', 'z=80', 'z=120', 'z=160');

figure(2);
semilogy(SNR_9x27_10, FER_9x27_10, '-*k');
hold on;
semilogy(SNR_9x27_20, FER_9x27_20, '-ok');
hold on;
semilogy(SNR_9x27_40, FER_9x27_40, '-sk');
hold on;
semilogy(SNR_9x27_60, FER_9x27_60, '->k');
hold on;
semilogy(SNR_9x27_80, FER_9x27_80, '-<k');
hold on;
semilogy(SNR_9x27_120, FER_9x27_120, '-xk');
hold on;
semilogy(SNR_9x27_160, FER_9x27_160, '-dk');
grid on;
title('FER of 2/3 QC-LDPC Codes');
xlabel('SNR(dB)');
ylabel('FER');
legend('z=10', 'z=20', 'z=40', 'z=60', 'z=80', 'z=120', 'z=160');

figure(3);
semilogy(SNR_4x20_90, BER_4x20_90, '-*k');
hold on;
semilogy(SNR_4x20_120, BER_4x20_120, '-ok');
hold on;
semilogy(SNR_4x20_150, BER_4x20_150, '-sk');
hold on;
semilogy(SNR_4x20_180, BER_4x20_180, '->k');
hold on;
semilogy(SNR_4x20_240, BER_4x20_240, '-<k');
grid on;
title('BER of 4/5 QC-LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER');
legend('z=90', 'z=120', 'z=150', 'z=180', 'z=240');

figure(4);
semilogy(SNR_4x20_90, FER_4x20_90, '-*k');
hold on;
semilogy(SNR_4x20_120, FER_4x20_120, '-ok');
hold on;
semilogy(SNR_4x20_150, FER_4x20_150, '-sk');
hold on;
semilogy(SNR_4x20_180, FER_4x20_180, '->k');
hold on;
semilogy(SNR_4x20_240, FER_4x20_240, '-<k');
grid on;
title('FER of 4/5 QC-LDPC Codes');
xlabel('SNR(dB)');
ylabel('FER');
legend('z=90', 'z=120', 'z=150', 'z=180', 'z=240');


figure(7);
semilogy(SNR_9x27_40, BER_9x27_40, '-*k');
hold on;
semilogy(SNR_9x27_40, BER_2d3r_1080, '-ok');
hold on;
semilogy(SNR_9x27_40, FER_9x27_40, '--*k');
hold on;
semilogy(SNR_9x27_40, FER_2d3r_1080, '--ok');
grid on;
title('Comparison of (1080, 720) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(9);
semilogy(SNR_9x27_80, BER_9x27_80, '-*k');
hold on;
semilogy(SNR_9x27_80, BER_2d3r_2160, '-ok');
hold on;
semilogy(SNR_9x27_80, FER_9x27_80, '--*k');
hold on;
semilogy(SNR_9x27_80, FER_2d3r_2160, '--ok');
grid on;
title('Comparison of (2160, 1440) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(11);
semilogy(SNR_9x27_160, BER_9x27_160, '-*k');
hold on;
semilogy(SNR_9x27_160, BER_2d3r_4320, '-ok');
hold on;
semilogy(SNR_9x27_160, FER_9x27_160, '--*k');
hold on;
semilogy(SNR_9x27_160, FER_2d3r_4320, '--ok');
grid on;
title('Comparison of (4320, 2880) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(12);
semilogy(SNR_4x20_90, BER_4x20_90, '-*k');
hold on;
semilogy(SNR_4x20_90, BER_4d5r_1800, '-ok');
hold on;
semilogy(SNR_4x20_90, FER_4x20_90, '--*k');
hold on;
semilogy(SNR_4x20_90, FER_4d5r_1800, '--ok');
grid on;
title('Comparison of (1800, 1440) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(13);
semilogy(SNR_4x20_120, BER_4x20_120, '-*k');
hold on;
semilogy(SNR_4x20_120, BER_4d5r_2400, '-ok');
hold on;
semilogy(SNR_4x20_120, FER_4x20_120, '--*k');
hold on;
semilogy(SNR_4x20_120, FER_4d5r_2400, '--ok');
grid on;
title('Comparison of (2400, 1920) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(14);
semilogy(SNR_4x20_150, BER_4x20_150, '-*k');
hold on;
semilogy(SNR_4x20_150, BER_4d5r_3000, '-ok');
hold on;
semilogy(SNR_4x20_150, FER_4x20_150, '--*k');
hold on;
semilogy(SNR_4x20_150, FER_4d5r_3000, '--ok');
grid on;
title('Comparison of (3000, 2400) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(15);
semilogy(SNR_4x20_180, BER_4x20_180, '-*k');
hold on;
semilogy(SNR_4x20_180, BER_4d5r_3600, '-ok');
hold on;
semilogy(SNR_4x20_180, FER_4x20_180, '--*k');
hold on;
semilogy(SNR_4x20_180, FER_4d5r_3600, '--ok');
grid on;
title('Comparison of (3600, 2880) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');

figure(16);
semilogy(SNR_4x20_240, BER_4x20_240, '-*k');
hold on;
semilogy(SNR_4x20_240, BER_4d5r_4800, '-ok');
hold on;
semilogy(SNR_4x20_240, FER_4x20_240, '--*k');
hold on;
semilogy(SNR_4x20_240, FER_4d5r_4800, '--ok');
grid on;
title('Comparison of (4800, 3840) LDPC Codes');
xlabel('SNR(dB)');
ylabel('BER/FER');
legend('BER for QC-LDPC', 'BER for Random LDPC', 'FER for QC-LDPC', 'FER for Random LDPC');


aa = 0;